<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:cc="http://xmlns.jcp.org/jsf/composite"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">

    <!-- INTERFACE -->
    <cc:interface>

        <cc:attribute name="event" type="com.aljfce.business.entity.Event"/>
        <cc:attribute name="weather" />
        <cc:attribute name="nextSunnyDay" default=""/>
        <cc:attribute name="widgetVar" required="true"/>
        <cc:attribute name="componentId" required="true"/>
        <!-- Buttons with actions -->
        <cc:attribute name="leftBtnLabel" />
        <cc:attribute name="leftBtnAction" method-signature="java.lang.String action()" />
        <cc:attribute name="rightBtnLabel" />
        <cc:attribute name="rightBtnAction" method-signature="java.lang.String action()" />

        <cc:attribute name="type" />
                

    </cc:interface>

    <!-- IMPLEMENTATION -->
    <cc:implementation>
        <p:dialog header="#{cc.attrs.event.title}" widgetVar="#{cc.attrs.widgetVar}"  id="#{cc.attrs.componentId}" appendTo="@(body)" modal="true" width="400" resizable="false" >
            <p:outputPanel >
                <p>
                    <h:outputLabel value="Description" styleClass="bold-label"/> <br/>
                    <p:scrollPanel mode="native" style="width:350px;height:200px; margin:auto;">
                        <h:outputText value="#{cc.attrs.event.description}"/> <br/>
                    </p:scrollPanel>
                </p>
                
                <c:if test="#{cc.attrs.type != eventDetailBean.OWN_EVENT}">
                    <p>
                        <h:outputLabel value="Creator: " styleClass="bold-label"/>   
                        <h:outputText value="#{cc.attrs.event.creator.name} #{cc.attrs.event.creator.surname}" />
                    </p>
                </c:if>

                <p>
                    <h:outputLabel value="Starting Date: " styleClass="bold-label"/>   
                    <h:outputText value="#{cc.attrs.event.startingDate}" >
                        <f:convertDateTime pattern="dd/MM/yyyy HH:mm" />
                    </h:outputText>
                </p>
                <p>
                    <h:outputLabel value="Ending Date: " styleClass="bold-label"/> 
                    <h:outputText value="#{cc.attrs.event.endingTime}" > 
                        <f:convertDateTime pattern="dd/MM/yyyy HH:mm" />
                    </h:outputText>
                </p>
                <p>
                    <h:outputLabel value="Location" styleClass="bold-label"/> <br/>
                    <h:outputText value="#{cc.attrs.event.location}" rendered="#{not empty cc.attrs.event.location}"/>

                </p>
                <p>
                    <h:outputLabel value="#{not empty cc.attrs.event.outdoor? 'Event is ourdoor' : 'Event is indoor' }"  styleClass="bold-label"/>
                </p>
                <p>
                    <h:outputLabel value="Weather information" rendered="#{not empty cc.attrs.weather}" styleClass="bold-label"/> <br/>
                    <h:outputText value="#{cc.attrs.weather}" rendered="#{not empty cc.attrs.weather}" /> <br/>
                </p>
                <p>
                    <h:outputText value="Next Sunny Day" rendered="#{not empty cc.attrs.nextSunnyDay}" styleClass="bold-label"/>
                    <h:outputText value="#{cc.attrs.nextSunnyDay}" rendered="#{not empty cc.attrs.nextSunnyDay}" />
                </p>
                <p>

                    <c:choose>
                        <c:when test="#{cc.attrs.type == eventDetailBean.IN_CALENDAR_EVENT}">

                            <p:commandButton value="Delete Event" action="#{acceptedEvent.delete(event)}" oncomplete="PF('#{cc.attrs.widgetVar}').hide()"/>

                        </c:when>
                        <c:when test="#{cc.attrs.type == eventDetailBean.INVITED_EVENT}">
                            <p:commandButton value="Accept" action="#{invitedEvent.accept(event)}" oncomplete="PF('#{cc.attrs.widgetVar}').hide()"/>
                            <p:commandButton value="Decline" action="#{invitedEvent.decline(event)}" oncomplete="PF('#{cc.attrs.widgetVar}').hide()"/>
                        </c:when>
                        <c:when test="#{cc.attrs.type == eventDetailBean.OWN_EVENT}">       
                            <p:commandButton value="Edit" action="#{ownEvent.edit(event)}" oncomplete="PF('#{cc.attrs.widgetVar}').hide()"/>
                            <p:commandButton value="Delete" action="#{ownEvent.delete(event)}" oncomplete="PF('#{cc.attrs.widgetVar}').hide()"/>
                        </c:when>
                    </c:choose>
                </p>

            </p:outputPanel>
        </p:dialog>
    </cc:implementation>
</html>